<!--
 * @Description: In User Settings Edit
 * @Author: your name
 * @Date: 2019-08-07 13:41:28
 * @LastEditTime: 2020-03-17 19:57:22
 * @LastEditors: Please set LastEditors
 -->
<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0,viewport-fit=cover" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>Hello APP</title>
    <link rel="stylesheet" type="text/css" href="../css/vant.css">
    <link rel="stylesheet" type="text/css" href="../css/base.css" />
    <script type="text/javascript" src="../script/jquery.js"></script>
    <script type="text/javascript" src="../script/layer/mobile/layer.js"></script>
    <script type="text/javascript" src="../script/vue.min.js"></script>
    <script type="text/javascript" src="../script/vant.min.js"></script>
    <script type="text/javascript" src="../script/fastclick.js"></script>
    <script type="text/javascript" src="../script/base.js"></script>
    <style type="text/css">
        .head {
            background: #f2f2f2 !important;
        }

        .van-nav-bar__title {
            color: #000;
        }

        .bg {
            position: relative;
        }

        .bg .m-b {
            width: 100%;
        }

        .h-t {
            margin-top: -43px;
            position: relative;
            z-index: 1;
            text-align: center;
        }

        .h-t .user-img {
            width: 70px;
            height: 70px;
            padding: 10px;
            border-radius: 35px;
            overflow: hidden;
            background: #fff;
            display: inline-block;
        }

        .h-t .user-img img {
            width: 100%;
            height: 100%;
            border-radius: 35px;
        }

        .part {
            padding: 10px 0 0;
        }

        .part>div {
            background: #fff;
            border-radius: 4px;
        }

        .part .van-cell__title {
            max-width: none;
            font-weight: 500;
            color: #797a7b;
        }

        .part img {
            width: 16px;
            height: 16px;
            margin-top: 4px;
            margin-right: 8px;
        }

        .other {
            background: #fff;
            border-bottom: 1px solid #ebedf0;
            text-align: center;
            color: #5b5b5b;
            font-size: 16px;
            padding: 8px 0 5px 0;
        }

        .other .money {
            font-size: 15px;
            color: #b91627;
            font-weight: 700;
            margin-top: 4px;
        }

        .login-out {
            height: 38px;
            line-height: 36px;
        }

        .code{
            color: #000;
        }
    </style>
</head>

<body>
    <div id="app" v-cloak>
        <div class="init-full">
            <van-nav-bar  class="head" :title="userInfo.S_BranchName"></van-nav-bar>
            <div class="body-no-bottom">
                <div class="content">
                    <div class="bg">
                        <img class="m-b" src="../image/ming-bg.png" />
                        <!-- <div class="header">
                            <div class="user-img">
                                <img :src="userInfo.S_HeadImg?userInfo.S_HeadImg:'../image/header.png'" />
                            </div>
                            <div class="user-info">
                                <div>{{userInfo.S_BranchName}}</div>
                                <div>{{userInfo.UserCode}}</div>
                            </div>
                        </div> -->
                    </div>
                    <div class="other">
                        <van-row>
                            <van-col span="1"></van-col>
                            <van-col span="7">
                                <div class="h-t">
                                    <div class="user-img">
                                        <img :src="userInfo.S_HeadImg?userInfo.S_HeadImg:'../image/header.png'"></div>
                                    <div class="code">{{userInfo.UserCode}}</div>
                                </div>

                            </van-col>
                            <van-col span="5"  v-if="userInfo.S_Type == 1">
                                <div>账户余额</div>
                                <div class="money">￥{{statistics.YEMoney}}</div>
                            </van-col>
                            <van-col span="5" v-if="userInfo.S_Type == 1">
                                <div>可提现</div>
                                <div class="money">￥{{statistics.KYMoney}}</div>
                            </van-col>
                            <van-col span="5" v-if="userInfo.S_Type == 1">
                                <div>本月收益</div>
                                <div class="money">￥{{statistics.SYMoney}}</div>
                            </van-col>

                            <van-col span="5"  v-if="userInfo.S_Type == 2">
                                <div>出勤</div>
                                <div class="money">{{kqData.CQTS}}天</div>
                            </van-col>
                            <van-col span="5" v-if="userInfo.S_Type == 2">
                                <div>缺卡</div>
                                <div class="money">{{kqData.QKCS}}次</div>
                            </van-col>
                            <van-col span="5" v-if="userInfo.S_Type == 2">
                                <div>迟到</div>
                                <div class="money">{{kqData.CDCS}}次</div>
                            </van-col>
                        </van-row>
                    </div>
                    <div class="part">
                        <div>
                            <van-cell title="在线支付记录" is-link @click="openWinPage('payRecord')" v-if="userInfo.S_Type == 1">
                                <img slot="icon" src="../image/payRecord.png" />
                            </van-cell>
                            <van-cell title="账户明细" is-link @click="openWinPage('accountDetail')">
                                <img slot="icon" src="../image/detail.png" />
                            </van-cell>
                            <van-cell title="个人信息" is-link @click="openWinPage('userInfo')">
                                <img slot="icon" src="../image/userInfo.png" />
                            </van-cell>
                            <van-cell title="密码修改" is-link @click="openWinPage('passwordEdit')">
                                <img slot="icon" src="../image/password.png" />
                            </van-cell>
                            <van-cell title="打印设置" is-link @click="openWinPage('common/printConfig')">
                                <img slot="icon" src="../image/printConfig.png" />
                            </van-cell>
                            <van-cell title="设置" is-link @click="openWinPage('config')">
                                <img slot="icon" src="../image/appConfig.png" />
                            </van-cell>
                            <van-cell title="帮助教程" is-link @click="openWinPage('appHelp')">
                                <img slot="icon" src="../image/help.png" />
                            </van-cell>
                        </div>
                    </div>
                    <div class="part">
                        <div>
                            <van-cell title="关于我们" is-link @click="openWinPage('aboutUs')">
                                <img slot="icon" src="../image/aboutUs.png" />
                            </van-cell>
                        </div>
                    </div>
                    <div class="part">
                        <van-button type="primary" class="login-out" block @click="loginOut">退出登录</van-button>
                    </div>
                </div>
                <van-loading v-if="showLoading" />
            </div>
        </div>
    </div>
</body>
<script type="text/javascript">
    var vm;
    apiready = function () {
        //$('.init-full').show();
        var userInfo = FLD.getUserInfo();
        vm = new Vue({
            el: '#app',
            data: {
                showLoading: false,
                userInfo: userInfo,
                statistics: [],
                kqData: '',
            },
            created: function () {
                var that = this;
                setInterval(function () {
                    that.getUserfulData();
                }, 5000)
                that.getUserfulData();
                that.getKQData();

            },
            methods: {
                getKQData() {
					var that = this;
					var date1 = new Date();
					date1.setDate(1);

					var date_ = new Date();
					var currentMonth = date_.getMonth();
					var nextMonth = ++currentMonth;
					var nextMonthFirstDay = new Date(date_.getFullYear(), nextMonth, 1);
					var oneDay = 1000 * 60 * 60 * 24;
					var date2 = new Date(nextMonthFirstDay - oneDay)
					var obj = {
						S_XSDate: FLD.getFormatDate(date1).split(' ')[0],
						S_XEDate: FLD.getFormatDate(date2).split(' ')[0]
					}
					FLD.ajax('APP_YHKQTJRH', obj, function (res) {
						// console.log(JSON.stringify(res))
						that.kqData = res.ds[0];
					})
				},
                getUserfulData() {
                    var that = this;
                    FLD.ajax('AP_SYSJTJ', { S_BranchID: userInfo.S_BranchID }, function (res) {
                        that.statistics = res.ds1[0];
                    })
                },
                openWinPage(url) {
                    api.openWin({
                        name: url,
                        url: url + '.html',
                        reload: true,
                        slidBackEnabled: false
                    })
                },
                loginOut() {
                    this.$dialog.confirm({
                        title: '提示',
                        message: '是否退出福路德连锁?'
                    }).then(() => {
                        window.localStorage.removeItem('printData');
                        window.localStorage.removeItem('userInfo');
                        api.sendEvent({
                            name: 'clearLoginInfo'
                        });
                        api.closeToWin({
                            name: 'root'
                        });
                    }).catch(() => {

                    });
                }
            }
        })
    };
</script>

</html>